package com.zq.zqmanager.mapper;

import com.zq.zqmanager.dynamicsql.CatDynamicSqlProvider;
import com.zq.zqmanager.entity.Cat;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @program: zqmanager
 * @Date: 2020/2/24 17:44
 * @Author: zhengqiang
 * @Description:
 */
@Mapper
public interface CatMapper {

    @Select("select * from cat")
    public List<Cat> getAll();

    @Insert("insert into cat(cat_name,cat_age) values (#{catName},#{catAge})")
    @Options(useGeneratedKeys = true,keyProperty = "id" ,keyColumn = "id")
    public void insert(Cat cat);

//    @Select({"<script>"+
//            "select * from cat where 1=1 "
//            +"<if test=\"catName!=null and catName != ''\"> and cat_name = #{catName}</if>"
//            +"</script>"})
//    @Select({"<script> " +
//            "select * from cat " +
//            "where  1=1 " +
//            "<if test='catAge!=null'> and cat_age = #{catAge}</if> " +
//            "</script>"})
    @SelectProvider(type = CatDynamicSqlProvider.class,method = "select")
    public List<Cat> selectByParams(Cat cat);


}
